<%@ page contentType="text/html;charset=UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title>附件单个录入案例-附件列表</title>
	<%@ include file="/common/import.jsp" %>
    <%@ include file="/common/meta.jsp" %>
	<script>
	    $(function(){
    	    loadAttas();
	    })
	
	var atta_list_do = '${ctx}/attachment/store/list!data.action';
		
	//加载附件列表
	function loadAttas(){
		$.ajax({
			  url: atta_list_do,
			  type:'POST',
			  cache: false,
			  data:'objId=${objId}&objType=${objType}&attaSort='+$("input[name='attaSort']:checked").val(),
			  success: function(data){
			    $('#results').html(data);
			  }
			});
	}
	
	//关闭
	function closeAdd(){
	  $('#saveDiv').window('close');
	}
	
	//修改
	function updAttaStore(id,attachmentName){		
		var url = '${ctx}/attachment/store/edit.action?id='+id+'&objId=${objId}&objType=${objType}';
		$('#saveFrame').attr("title",attachmentName);
		$('#saveFrame').attr("src",url);
		$('#saveDiv').window('open');
	}
		
	// 增加
	function addAttaStore(){
		$('#saveFrame').html('');			
		var url = '${ctx}/attachment/store/add.action?objId=${objId}&objType=${objType}';			
		$('#saveFrame').attr("title",'');
		$('#saveFrame').attr("src",url);
		$('#saveDiv').window('open');	
	}	
	
	//删除
	function delAttaStore(id,name){
		$.messager.confirm('确认','您确定要删除:<font color=red>'+name+'</font> ？',function(r){
			if(r){
				 $.ajax({
					type:'post',
					url:'${ctx}/attachment/store/del.action',
					data:'id='+id+'&attaSort='+$("input[name='attaSort']:checked").val(),
					dataType:'json',
					success:function(data){
					     if("T"==data.flag){
					     	$.messager.alert("删除结果",data.msg, "info");
					     	loadAttas();
					     }else{
					     	$.messager.alert("删除结果",data.msg, "error");
					     	loadAttas();
					     }
						},
					error:function(){
						 $.messager.alert("删除结果","未知异常", "error");
						}
					});
		 	}
	  	});
	}
	
	function clickAttaSort(type){
<%--	   if(type=="1"){--%>
<%--	     //window.location.href="${ctx}/attachment/store/toPicList.action?objId=atta&objType=uploadPicOne";--%>
<%--	     window.location.href="${ctx}/attachment/store/list.action?objId=${objId}&objType=${objType}";--%>
<%--	   }--%>
	}
	</script>
	<style>
	body,ul,p,div,img,li,a{margin:0;padding:0;border:0;font-family:"宋体";color:#000;font-size:12px;}
	.cls{clear:both; height:0px; line-height:0px; overflow:hidden; font-size:0px;}
	.attadiv ul{padding:10px;}
	.attadiv a{boder:none;}
	.attadiv li{float:left;padding-top:5px; padding-bottom:10px; width:85px; overflow:hidden; text-align:center; border-bottom:1px solid #619FCF;}
	.attadiv p.name{line-height:20px; height:40px; width:75px; overflow:hidden; color:#000;}
	.tools a{color:#619FCF;}
	.atta_Store_form{padding:10px;}
</style>
</head>
<body>
<div style="padding:5px 0;">
<span>				  
 <input type="radio" name="attaSort" value="0"  checked=checked onclick="clickAttaSort('0')" />&nbsp;附件
 <input type="radio" name="attaSort" value="1" onclick="clickAttaSort('1')" />&nbsp;图片
</span>	&nbsp;&nbsp;
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add'" title="上传附件" onclick="javascript:addAttaStore();">上传附件</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="javascript:loadAttas();" >刷新列表</a>
	</div>

    <div id="results"  title="附件列表" class="easyui-panel" style="height:330px;" data-options="iconCls:'icon-save',collapsible:true,maximizable:true"></div>

    <!-- 上传、修改窗口 -->
	<div id="saveDiv" class="easyui-window" title="附件上传" style="padding:5px;width: 550px;height:300px;" 	
    	iconCls="icon-edit" closed="true" maximizable="false" minimizable="false" collapsible="false">
   		<iframe frameborder="0"  id="saveFrame" height="100%" width="100%" scrolling="No" frameborder="0" ></iframe>
    </div>


</body>
</html>